<template>
    <!-- homeSub/pages/platformAnnouncement/platformAnnouncement.wxml -->
    <view :style="objColor">
        <view v-if="platformAnnouncement.id">
            <view class="platformAnnouncement">
                <view class="platformAnnouncement-header">
                    <view class="platformAnnouncement-header-title">{{ platformAnnouncement.name }}</view>
                    <view class="platformAnnouncement-header-time">{{ platformAnnouncement.releaseTime ? platformAnnouncement.releaseTime : '' }}</view>
                </view>
                <view class="platformAnnouncement-content">
                    <!-- {{ platformAnnouncement.content }} -->
                    <rich-text :nodes="platformAnnouncement.content" style="width: 100%"></rich-text>
                </view>
            </view>
            <view class="rightNow" v-if="platformAnnouncement.linkType == 0 || platformAnnouncement.linkType == 5" @tap="naviVebView">立即前往</view>
        </view>
        <Upgrading text="暂无内容" v-else></Upgrading>
    </view>
</template>

<script>
'use strict';
import Upgrading from '../../../components/upgrading/upgrading';

// exports.__esModule = true; // homeSub/pages/platformAnnouncement/platformAnnouncement.ts

var https_1 = require('./../../../api/https.js');

var app = getApp();

export default {
    components: {
        Upgrading
    },
    data() {
        return {
            platformAnnouncement: {
                id: '',
                name: '',
                releaseTime: false,
                content: '',
                linkUrl: '',
				mobilePath: '',
				linkType: null
            },
            linkUrl: ''
        };
    },
    /**
     * 生命周期函数--监听页面加载
     */
    onLoad: function (options) {
        this.messageById(options.id);
    },
    methods: {
        messageById: function (id) {
            var that = this;
            https_1
                .getMessageById({
                    messageId: id
                })
                .then(function (res) {
                    if (res.code == 0) {
                        // console.log(res.data)
                        that.platformAnnouncement=res.data,
                            that.linkUrl=res.data.linkUrl
                    } else if (res.code == 4) {
                        that.platformAnnouncement={}
                    }
                })
                ['catch'](function (err) {
                    console.log(err);
                });
        },

        naviVebView: function () {
            console.log('this.platformAnnouncement', this.platformAnnouncement.linkType)
            
			if(this.platformAnnouncement.linkType == 0) {
                app.globalData.CHECK_LOGIN(()=>{
                    if (/^http/.test(this.linkUrl)) {
                        // #ifdef APP-PLUS
                        plus.runtime.openURL(this.linkUrl);
                        // #endif
                        // #ifdef H5
                        window.location.href = this.linkUrl
                        // #endif
                        // #ifdef MP-WEIXIN
                        uni.navigateTo({
                            url: '../../pages/webView/webView?url=' + this.linkUrl
                        });
                        // #endif
                    }
                })
			} else if(this.platformAnnouncement.linkType == 5) {
                app.globalData.CHECK_LOGIN(()=>{
                    if(this.platformAnnouncement.mobilePath){
                        uni.navigateTo({
                            url: this.platformAnnouncement.mobilePath
                        });
				    }
                })
				
			}
        }
    }
};
</script>
<style lang="less">
	@import url('./platformAnnouncement.less');     
/* homeSub/pages/platformAnnouncement/platformAnnouncement.wxss */
</style>
